-- SteamMachine
-- Create by panyl
-- 幽灵船对象

SteamMachine = {
    classId = 0,

    -- 对象类型为蒸汽机械
    type = OBJECT_TYPE_STEAM_MACHINE,
};
SteamMachine.__index = SteamMachine;

-- 构造函数
function SteamMachine.new(classId, data)
    local self = {};
    setmetatable(self, SteamMachine);
    self.classId = classId;
    self.dbase = Dbase.new(data);

    for key, value in pairs(data) do
        self[key] = value;
    end

    return self;
end

-- 取得该对象的描述字符串
function SteamMachine:get_ob_id()
    return string.format("SteamMachine:%s", tostring(self.classId));
end

-- 查找数据
function SteamMachine:query(path, path2, default)
    if path == "classId" or path == "class_id" then
        return self.classId;
    elseif path == "level"  then return self.level;
    else
        local v = self.dbase:query(path, path2, default);
        if v then
            return v;
        else
            return SteamMachineM.query(self.classId, path);
        end
    end
end

-- 查询属性
function SteamMachine:queryAttrib(attrib, args)
    return AttribM.queryAttrib(self, attrib, args);
end

-- 计算基础攻击值
function SteamMachine:getAttack()
    return self:queryAttrib("attack");
end

-- 计算基础魔法值
function SteamMachine:getMagic()
    return self:queryAttrib("magic");
end

-- 命中
function SteamMachine:getAccuracy()
    return self:queryAttrib("accuracy");
end

-- 闪避
function SteamMachine:getDodge()
    return self:queryAttrib("dodge");
end

-- 获取等级
function SteamMachine:getLevel()
    return self:queryAttrib("level");
end

function SteamMachine:getRank()
    return self:queryAttrib("rank");
end

-- 名称
function SteamMachine:getName()
    return self:query("name");
end

-- 判断是否是boss
function SteamMachine:isBoss()
    return false;
end

-- 是否是冈布奥怪
function SteamMachine:isSlime()
    return false;
end

-- 是否是观众怪
function SteamMachine:isAudience()
    return false;
end

-- 获取属主
function SteamMachine:getOwner()
    return ME.user;
end

function SteamMachine:getPos()
    return self.pos or self.dbase:query("pos");
end

-- 倒计时
function SteamMachine:getCountDown()
    return SteamMachineM.getAttackCountDown(self);
end

-- 受创
function SteamMachine:receiveDamage(damage)
    -- do nothing
end

function SteamMachine:die()
    -- do nothing
    return false;
end
